package poker;
import javax.swing.*;
import java.awt.*;

public class KaartGUI extends JPanel
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Color backGround = new Color(0, 128, 0);		// groen zoals poker tafel
	
	public boolean drawDealerButton = false;
	public Image i = Toolkit.getDefaultToolkit().getImage("img\\beach.jpg");
	
	private Kaart k1;
	private Kaart k2;
	private HoofdSchermGUI hs;
	boolean showKaarten;
	
	public KaartGUI(Kaart k1, Kaart k2, HoofdSchermGUI hs)
	{
		this.k1 = k1;
		this.k2 = k2;
		this.hs = hs;
		setBackground( backGround );
		setPreferredSize( new Dimension(80, 60) );
	}
	
	public void removeCards()
	{
		k1 = null;
		k2 = null;
	}
	
	public void setImage(Image i)
	{	
		this.i = i;
		validate();
		repaint();
	}
	
	public void paintComponent(Graphics g)
	{
		g.setColor( backGround );
		g.fillRect(0, 0, getWidth(), getHeight() );
		
		g.setColor(Color.BLACK);
		
		if(showKaarten)
		{
			if(k1 != null)
				g.drawImage(k1.getImage(), 10, 10, 54, 72, backGround, this);
			//g.drawImage(k1.getImage(), 10, 10, 54, 72, backGround, this);
			if(k2 != null)
				g.drawImage(k2.getImage(), 20, 20, 54, 72, backGround, this);
		} else {
			if(k1 != null || k2 != null)
			{
				g.drawImage(hs.backSideCard, 10, 10, 54, 72, backGround, this);
				g.drawImage(hs.backSideCard, 20, 20, 54, 72, backGround, this);
			}
		}
		
		if(drawDealerButton)
		{
			g.setColor(Color.RED);
			g.fillOval(2, 41, 15, 15);
			g.setColor(Color.YELLOW);
			g.drawString("D", 7, 53);
		}
	}
}
